/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.melhoroferta.persistencia;

import br.com.melhoroferta.entidades.Categorias;


/**
 *
 * @author Marcio
 */
public class Generico extends DAO{
    
    public java.sql.ResultSet ultimaSolicitacoes(){
    
       try{
              openDataBase();
              pstmt = con.prepareStatement("SELECT NSolicitacao, U.Apelido, Produto, Descricao, S.UA AS UASolicitacao "
                      + "FROM Solicitacoes S INNER JOIN Usuarios U ON S.NUsuario = U.NUsuario"
                      + " WHERE Status= 1 ORDER BY S.UA DESC LIMIT 0,5 ");                                                                   
               rs = pstmt.executeQuery();
          }catch(Exception e){
                System.out.println(e.getMessage());
          
          }
        return rs;
    }
    
    public java.sql.ResultSet maisPedidas(){
        
           try{
              openDataBase();
              pstmt = con.prepareStatement("SELECT SSC.NCategoria, COUNT(DISTINCT NSolicitacao) AS Total, Nome "
                      + "FROM SolicitacaoSubCategorias SSC INNER JOIN Categorias C ON SSC.NCategoria = C.NCategoria "
                      + "GROUP BY NCategoria ORDER BY Total DESC LIMIT 0,20");                                                                   
               rs = pstmt.executeQuery();
          }catch(Exception e){
                System.out.println(e.getMessage());
          }
        return rs;
    }
}
